"""
管理所有的resource,可以通过此类获取制定resource方法
"""
from client_resource.resource_factory import ResourceFactory


class ResourceManager:
    def __init__(self, config):
        self._service_map = {}
        for conf in config:
            self._service_map[conf["name"]] = conf

    def get_service(self, name):
        """
        根据resource name ,调用 resource factory 构建
        :return:
        """
        conf = self._service_map[name]
        service = ResourceFactory.create_service(conf)
        return service
